package com.lzy.constant;

import org.springframework.util.StringUtils;

/**
 * @author lzy by 2019/8/30 14:36
 */
public enum BaseImgEnum {

    HTML("html", "data:text/html;base64,", "base64编码的HTML代码"),
    CSS("css", "data:text/css;base64,", "base64编码的CSS代码"),
    JAVASCRIPT("javascript", "data:text/javascript;base64,", "base64编码的Javascript代码"),
    GIF("gif", "data:image/gif;base64,", "base64编码的gif图片数据"),
    PNG("png", "data:image/png;base64,", "base64编码的png图片数据"),
    JPEG("jpeg", "data:image/jpeg;base64,", "base64编码的jpeg图片数据"),
    ICON("icon", "data:image/x-icon;base64,", "base64编码的icon图片数据"),
    ;

    private String code;
    private String value;
    private String text;

    BaseImgEnum(String code, String value, String text) {
        this.code = code;
        this.value = value;
        this.text = text;
    }

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    public static BaseImgEnum valueOfCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (BaseImgEnum anEnum : BaseImgEnum.values()) {
            if (anEnum.code.equals(code)) {
                return anEnum;
            }
        }
        return null;
    }
}
